package process_demo.review.about_volatile;

import java.util.concurrent.TimeUnit;

/**
 * @author haomin
 * @date 2022/09/11 15:46
 **/
public class Main {
    volatile static boolean flag = false;
    static class MyThread extends Thread{
        @Override
        public void run() {
            long r = 0;
            while (flag == false){
                r++;
            }
            System.out.println(r);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();
        t.start();

        TimeUnit.SECONDS.sleep(2);
        flag = true;
    }
}